﻿using UnityEngine;
using System.Collections;

public class ColorChanger : MonoBehaviour 
{
	public float refreshRate;
	private float counter;

	void Awake()
	{
		counter = refreshRate;
	}

	void FixedUpdate()
	{
		if(counter < 0)
		{
			// pick a random color
			Color newColor = new Color( Random.value, Random.value, Random.value, 1.0f );
			
			// apply it on current object's material
			renderer.material.color = newColor; 
			renderer.material.SetColor("_TintColor", newColor);
			counter = refreshRate;
		}
		else
		{
			counter -= Time.fixedDeltaTime;

		}
	}
}
